package com.gis.util;

public class RestResponse {
	private int code;
	private String message;
	private Object data;

	public RestResponse() {

	}

	public static RestResponse succuess() {
		RestResponse restResponse = new RestResponse();
		restResponse.setResultCode(ResultCode.SUCCESS);

		return restResponse;
	}
	
	public static RestResponse success(String message) {
		RestResponse restResponse = new RestResponse();
		restResponse.setCode(0);
		restResponse.setMessage(message);
		return restResponse;
	}
	
	public static RestResponse success(String message, Object data) {
		RestResponse restResponse = new RestResponse();
		restResponse.setCode(0);
		restResponse.setMessage(message);
		restResponse.setData(data);
		return restResponse;
	}

	public static RestResponse success(Object data) {
		RestResponse restResponse = new RestResponse();
		restResponse.setResultCode(ResultCode.SUCCESS);
		restResponse.setData(data);

		return restResponse;
	}

	public static RestResponse fail() {
		RestResponse restResponse = new RestResponse();
		restResponse.setResultCode(ResultCode.FAIL);

		return restResponse;
	}

	public static RestResponse fail(ResultCode resultCode) {
		RestResponse restResponse = new RestResponse();
		restResponse.setResultCode(resultCode);

		return restResponse;
	}

	public static RestResponse fail(String message) {
		RestResponse restResponse = new RestResponse();
		restResponse.setCode(ResultCode.FAIL.code());
		restResponse.setMessage(message);

		return restResponse;
	}

	public static RestResponse fail(Integer code, String message) {
		RestResponse restResponse = new RestResponse();
		restResponse.setCode(code);
		restResponse.setMessage(message);

		return restResponse;
	}

	public static RestResponse fail(ResultCode resultCode, Object data) {
		RestResponse restResponse = new RestResponse();
		restResponse.setResultCode(resultCode);
		restResponse.setData(data);

		return restResponse;
	}

	private void setResultCode(ResultCode resultCode) {
		this.code = resultCode.code();
		this.message = resultCode.message();
	}

	public void setData(Object data) {
		this.data = data;
	}

	public Object getData() {
		return data;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getMessage() {
		return message;
	}

	public void setMessage(String message) {
		this.message = message;
	}
}